{% extends 'LimsMainBundle::Layout/formLayout.html.twig' %}

{% block stylesheets %}
    {{ parent() }}
    <link href="/template/css/lims/credit.css" rel="stylesheet" type="text/css" />
{% endblock %}

{% block javascripts %}
    {{ parent() }}
    
    <script>var newRegisterNumber = {% if registerNumber is not null %}"{{registerNumber}}"{% else %}null{% endif %};</script>
    
    <script type="text/javascript" src="/template/js/lims/newCredit.js"></script>
    <script type="text/javascript" src="/template/js/lims/assetOwner.js"></script>
    <script type="text/javascript" src="/template/js/lims/creditPartner.js"></script>
    <script type="text/javascript" src="/template/js/lims/newSchedule.js"></script>
    <script type="text/javascript" src="/template/js/lims/addContract.js"></script>
    
{% endblock %}

{% block content %}

    {% include 'LimsMainBundle::Breadcrumb/breadcrumb.html.twig' with {'breadCrumbName' : 'Зээлдэгч иргэний мэдээлэл'} %} 
    <form action="{{path('lims_credit_create')}}" method="post" name="create_credit" autocomplete="off">
        <div class="row"> 
            <div class="col-md-12">
                <div class="block"> 
                    <div class="header list-item"> 
                        <h2>Зээлдэгч сонгох</h2> 
                    </div>
                    <div class="content controls" style="background: none repeat scroll 0 0 rgba(0, 0, 0, 0.3)">
                        <div class="form-row"> 
                            <div class="col-md-3"><label class="required">*</label> Зээлдэгчийн регистрийн дугаар : </div> 
                            <div class="col-md-9" id="newRegisterNumberCol"> 
                                <input type="hidden" tabindex="1" style="width:300px" class="input-xlarge" name="credit_register_number" id="credit_register_number" required="required"/>
                            </div> 
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <div class="block nav-tabs-vertical">
                    <div class="head bg-default bg-light">
                       <h2>Зээлийн мэдээлэл</h2>
                    </div>
                    <div class=tabs>
                        <ul class="nav nav-tabs">
                            <li class=active><a href=#tab19 data-toggle=tab><span class="icon-book"></span>&nbsp;&nbsp;&nbsp;Үндсэн мэдээлэл</a></li>
                            <li><a href=#tab22 data-toggle=tab><span class="icon-calendar"></span>&nbsp;&nbsp;&nbsp;Зээлийн хувиар</a></li>
                            <li><a href=#tab20 data-toggle=tab><span class="icon-home"></span>&nbsp;&nbsp;&nbsp;Барьцаа хөрөнгө</a></li>
                            <li><a href=#tab21 data-toggle=tab><span class="icon-group"></span>&nbsp;&nbsp;&nbsp;Хамтран зээлдэгч</a></li>
                            
                        </ul>
                        <div class="tab-content min-heigth-200">
                            <div class="tab-pane active" id="tab19">
                            <!-------------------------------------------------------------------------------------------->
                                <div class="col-md-6">

                                    <div class="form-row"> 
                                        <div class="col-md-3"><label class="required">*</label> Гэрээний дугаар : </div> 
                                        <div class="col-md-9">                                             
                                            <select class="select2 col-md-9 padding-none" tabindex="6" name="credit_contract_number" id="credit_contract_number"  required="required"> 
                                                <option value="">Сонгох</option>
                                                {% for contract in contractList %}
                                                    <option value="{{contract.ID}}">{{contract.NAME}}</option>
                                                {% endfor %}
                                            </select>
                                            <a class="btn btn-default btn-clean col-md-3" data-toggle="modal" onclick="openContractPopup()" href="#contractPopup">Нэмэх</a>
                                        </div> 
                                    </div>

                                    {#<div class="form-row"> 
                                        <div class="col-md-3">Гэрээ байгуулсан огноо : </div> 
                                        <div class="col-md-9"> 
                                            <div class="input-group padding-none col-md-6">
                                                <div class=input-group-addon>
                                                    <span class=icon-calendar-empty></span>
                                                </div> 
                                                <input type="text" class="datepicker" placeholder="Гэрээ байгуулсан огноо" name="credit_contract_date" id="credit_contract_date" tabindex="3"/>
                                            </div>
                                        </div> 
                                    </div>#}

                                    <div class="form-row"> 
                                        <div class="col-md-3"><label class="required">*</label> Зээлийн хамрах хугацаа : </div> 
                                        <div class="col-md-9"> 
                                            <div class="col-md-6 padding-none">
                                                <div class="input-group padding-none" class="col-md-6">
                                                    <div class=input-group-addon>
                                                        <span class=icon-calendar-empty></span>
                                                    </div> 
                                                    <input type="text" class="datepicker" placeholder="Эхлэх огноо" name="credit_begin_date" id="credit_begin_date" tabindex="4" required="required"/>
                                                </div>
                                            </div>
                                            <div class="col-md-6 padding-none">
                                                <div class="input-group padding-none" class="col-md-6">
                                                    <div class=input-group-addon>
                                                        <span class=icon-calendar-empty></span>
                                                    </div> 
                                                    <input type="text" class="datepicker" placeholder="Дуусах огноо" name="credit_end_date" id="credit_end_date" tabindex="5" required="required"/>
                                                </div>
                                            </div>
                                        </div> 
                                    </div> 

                                    <div class="form-row"> 
                                        <div class="col-md-3"><label class="required">*</label> Төрөл : </div> 
                                        <div class="col-md-9"> 
                                            <select class="select2 col-md-12 padding-none" tabindex="6" name="credit_type" id="credit_type" required="required"> 
                                                <option value="">Сонгох</option>
                                                {% for type in creditType %}
                                                    <option value="{{type.id}}">{{type.name}}</option>
                                                {% endfor %}
                                            </select>
                                        </div> 
                                    </div>

                                    <div class="form-row"> 
                                        <div class="col-md-3">Зориулалт : </div> 
                                        <div class="col-md-9"> 
                                            <select class="select2" style="width:100%" tabindex="7" name="credit_dedication" id="citizen_dedication"> 
                                                <option value="">Сонгох</option>
                                                {% for dedication in creditDedication %}
                                                    <option value="{{dedication.id}}">{{dedication.name}}</option>
                                                {% endfor %}
                                            </select>
                                        </div> 
                                    </div>

                                    <div class="form-row"> 
                                        <div class="col-md-3"><label class="required">*</label> Олгосон дүн : </div> 
                                        <div class="col-md-9"> 
                                            <input type="text" class="validate[required,minSize[10],maxSize[10]] col-md-10 currency" name="credit_initial_amount" id="credit_initial_amount" tabindex="6" onchange="calcTotalAmount()"/>
                                            <select class="select2 col-md-2 padding-right-none" tabindex="8" name="credit_currency_id" id="credit_currency_id" required="required" onchange="changeTotalCurrency()"> 
                                                <option value="">Сонгох</option>
                                                {% for currency in currencyList %}
                                                    <option value="{{currency.id}}" {% if currency.id == 1 %}selected="selected"{% endif %}>{{currency.symbol}}</option>
                                                {% endfor %}
                                            </select>
                                        </div> 
                                    </div>

                                    <div class="form-row"> 
                                        <div class="col-md-3"><label class="required">*</label> Хүүгийн хувь (Жилээр): </div> 
                                        <div class="col-md-9"> 
                                            <input type="text" class="validate[required,minSize[0],maxSize[3]] currency" maxlength="3" name="credit_interest_percent" id="credit_interest_percent" tabindex="9" required="required" onchange="changeInterest()"/>
                                        </div> 
                                    </div>

                                    <div class="form-row"> 
                                        <div class="col-md-3">Хүүгийн хэмжээ : </div> 
                                        <div class="col-md-9"> 
                                            <input type="text" class="validate[required,minSize[10],maxSize[10]] currency" name="credit_interest_amount" id="credit_interest_amount" tabindex="10" onchange="calcTotalAmount()"/>
                                        </div> 
                                    </div>

                                    <div class="form-row"> 
                                        <div class="col-md-3"><label class="required">*</label> Нийт зээлийн дүн : </div> 
                                        <div class="col-md-9"> 
                                            <input type="text" class="validate[required,minSize[10],maxSize[10]] currency" name="credit_total_amount" id="credit_total_amount" tabindex="11" required="required" readonly="readonly"/>                                       
                                        </div> 
                                    </div>

                                 </div>
                             <!-------------------------------------------------------------------------------------------->
                             <div class="col-md-6">

                                <div class="form-row"> 
                                    <div class="col-md-3">Зээлийн чанар : </div> 
                                    <div class="col-md-9"> 
                                        <select class="select2 col-md-12 padding-none" tabindex="12" name="credit_quality_map" id="credit_quality_map"> 
                                            <option value="">Сонгох</option>
                                            {% for creditQuality in creditQualityList %}
                                                <option value="{{creditQuality.id}}" {% if creditQuality.id == 1 %}selected="selected"{% endif %}>{{creditQuality.name}}</option>
                                            {% endfor %}
                                        </select>
                                    </div> 
                                </div>
                                 
                                <div class="form-row"> 
                                    <div class="col-md-3"><label class="required">*</label> Зээл төлөлтийн хэлбэр : </div> 
                                    <div class="col-md-9"> 
                                        <select class="select2 col-md-12 padding-none" tabindex="12" name="credit_payment_type" id="credit_payment_type" required="required" onchange="changePaymentType()"> 
                                            <option value="">Сонгох</option>
                                            {% for paymentType in creditPaymentType %}
                                                <option value="{{paymentType.id}}">{{paymentType.name}}</option>
                                            {% endfor %}
                                        </select>
                                    </div> 
                                </div>

                                {#<div class="form-row"> 
                                    <div class="col-md-3"><label class="required">*</label> Хүүгийн төлөлтийн хэлбэр : </div> 
                                    <div class="col-md-9"> 
                                        <select class="select2 col-md-12 padding-none" tabindex="13" name="credit_interest_payment_type" id="credit_interest_payment_type" required="required"> 
                                            <option value="">Сонгох</option>
                                            {% for paymentType in creditPaymentType %}
                                                <option value="{{paymentType.id}}">{{paymentType.name}}</option>
                                            {% endfor %}
                                        </select>
                                    </div> 
                                </div>#}

                                <div class="form-row"> 
                                    <div class="col-md-3">Нэмэлт мэдээлэл : </div> 
                                    <div class="col-md-9">
                                        <textarea name="credit_description" id="credit_description" tabindex="14"></textarea>
                                    </div> 
                                </div>

                             </div>
                             <!-------------------------------------------------------------------------------------------->
                            </div>
                            <div class="tab-pane" id="tab22">                                
                                <div class="col-md-12">
                                    <div class="block"> 
                                        
                                        <div class="row">
                                            <div class="col-md-4">
                                                <div class="block block-white"> 
                                                    <div class="header"> 
                                                        <h2>Зээлийн төлбөрийн хувиар</h2> 
                                                    </div> 
                                                    <div class="content">                                                         
                                                        <table class="table text-align-right">
                                                            <thead>
                                                                <tr>
                                                                    <th colspan="2">Зээлийн нөхцөл</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                <tr>
                                                                    <td>Зээлийн хэмжээ</td>
                                                                    <td><span id="schedule_total_amount"></span></td>
                                                                </tr>
                                                                <tr>
                                                                    <td>Жилийн хүү</td>
                                                                    <td><span id="schedule_intereset"></span>%</td>
                                                                </tr>
                                                                <tr>
                                                                    <td><label class="required">*</label> Зээлийн хугацаа /сар/</td>
                                                                    <td><input type="text" name="schedule_length" id="schedule_length" class="col-md-12 currency" maxlength="2" onchange="calcSchedule()"/></td>
                                                                </tr>
                                                                <tr>
                                                                    <td><label class="required">*</label> Зээл олгох огноо</td>
                                                                    <td><input type="text" class="datepicker" name="schedule[start_date]" id="schedule_start_date" onchange="calcSchedule()"></td>
                                                                </tr>
                                                                <tr>
                                                                    <td><label class="required">*</label> Эхний төлбөр хийх огноо</td>
                                                                    <td><input type="text" class="datepicker" name="schedule[payment_start_date]" id="schedule_payment_start_date" onchange="calcSchedule()"></td>
                                                                </tr>
                                                            </tbody>
                                                        </table>
                                                    </div>                                                     
                                                </div>
                                                
                                                <div class="block block-white">                                                     
                                                    <div class="content">                                                         
                                                        <table class="table text-align-right">                                                            
                                                            <tbody>
                                                                <tr>
                                                                    <td>Төлбөрийн хэлбэр</td>
                                                                    <td>
                                                                        <span id="schedule_payment_type_text">Үндсэн мэдээлэл хэсгээс сонголтоо хийнэ үү.</span>
                                                                        <input type="hidden" value="" id="schedule_payment_type" name="schedule_payment_type">
                                                                    
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td><label class="required">*</label> Сард төлөгдөх дүн</td>
                                                                    <td>
                                                                        <input type="text" class="col-md-6 currency" style="float: right;" id="schedule_amount_per_unit" name="schedule_amount_per_unit" placeholder="" />
                                                                    </td>
                                                                </tr>
                                                            </tbody>
                                                        </table>
                                                    </div>                                                     
                                                </div>
                                            </div>
                                            
                                            <div class="col-md-8">
                                                <div class="header"> 
                                                    <h2>Зээлийн хувиар</h2> 
                                                </div>                                        
                                                <table class="table table-bordered" id="schduleTable"> 
                                                    <thead> 
                                                        <tr> 
                                                            <th width="4%">#</th>                                                             
                                                            <th width="16%">Огноо</th> 
                                                            <th width="16%">Хоног</th> 
                                                            <th width="16%">ҮЗ төлбөр</th> 
                                                            <th width="16%">Хүү төлбөр</th> 
                                                            <th width="16%">Нийт төлбөр</th> 
                                                            <th width="16%">Зээлийн үлдэгдэл</th>                                                       
                                                        </tr> 
                                                    </thead> 
                                                    <tbody id="schduleTbody"> 

                                                    </tbody>
                                                </table>
                                                <input type="hidden" id="hiddenScheduleRowNum" value="0" />
                                            </div>
                                        </div>
                                        
                                        
                                        
                                    </div>
                                </div>                                
                            </div>
                            <div class=tab-pane id="tab20">
                                <div class="col-md-6">

                                    <div class="form-row"> 
                                        <div class="col-md-3">Барьцааны төрөл : </div> 
                                        <div class="col-md-9"> 
                                            <select class="select2 col-md-12 padding-none" name="asset_type" id="asset_type" tabindex="16"> 
                                                <option value="">Сонгох</option>
                                                {% for paymentType in creditPaymentType %}
                                                    <option value="{{paymentType.id}}">{{paymentType.name}}</option>
                                                {% endfor %}
                                            </select>
                                        </div> 
                                    </div>

                                    <div class="form-row"> 
                                        <div class="col-md-3">Улсын бүртгэлийн дугаар : </div> 
                                        <div class="col-md-9"> 
                                            <input type="text" class="form-control" name="asset_number" id="asset_number" tabindex="15"/>
                                        </div> 
                                    </div>

                                    <div class="form-row"> 
                                        <div class="col-md-3">Бүртгүүлсэн огноо : </div> 
                                        <div class="col-md-9"> 
                                            <div class="input-group padding-none col-md-6">
                                                <div class=input-group-addon>
                                                    <span class=icon-calendar-empty></span>
                                                </div> 
                                                <input type="text" class="datepicker" placeholder="Гэрээ байгуулсан огноо" name="asset_registered_date" id="asset_registered_date" tabindex="18"/>
                                            </div>
                                        </div> 
                                    </div>                                        

                                    <div class="form-row"> 
                                        <div class="col-md-3">Гэрчилгээний дугаар : </div> 
                                        <div class="col-md-9"> 
                                            <input type="text" class="form-control" name="asset_document_number" id="asset_document_number" tabindex="17"/>
                                        </div> 
                                    </div>

                                    <div class="form-row"> 
                                        <div class="col-md-3">Үнэлгээ хийсэн огноо : </div> 
                                        <div class="col-md-9"> 
                                            <div class="input-group padding-none col-md-6">
                                                <div class=input-group-addon>
                                                    <span class=icon-calendar-empty></span>
                                                </div> 
                                                <input type="text" class="datepicker" placeholder="Үнэлгээ хийсэн огноо" name="asset_validated_date" id="asset_validated_date" tabindex="18"/>
                                            </div>
                                        </div> 
                                    </div>

                                    <div class="form-row"> 
                                        <div class="col-md-3">Үнэлэгдсэн дүн : </div> 
                                        <div class="col-md-9">
                                            <input type="text" class="validate[required,minSize[10],maxSize[10]] col-md-10 currency" name="asset_total_amount" id="asset_total_amount" tabindex="19"/>
                                            <select class="select2 col-md-2 padding-right-none" tabindex="20" id="asset_currency" name="asset_currency"> 
                                                <option value="">Сонгох</option>
                                                {% for currency in currencyList %}
                                                    <option value="{{currency.id}}">{{currency.symbol}}</option>
                                                {% endfor %}
                                            </select>
                                        </div> 
                                    </div>

                                    <div class="form-row"> 
                                        <div class="col-md-3">Барьцаалах дүн : </div> 
                                        <div class="col-md-9"> 
                                            <div class="input-group padding-none col-md-6">
                                                <input type="text" class="form-control currency" name="asset_amount" id="asset_amount" tabindex="21"/>
                                            </div>
                                        </div> 
                                    </div>

                                    <div class="form-row"> 
                                        <div class="col-md-3">Нэмэлт мэдээлэл : </div> 
                                        <div class="col-md-9">
                                            <textarea name="asset_description" id="asset_description" tabindex="22"></textarea>
                                        </div> 
                                    </div>

                                </div>
                                <div class="col-md-6">
                                    <div class="block"> 
                                        <div class="header"> 
                                            <h2>Барьцаа хөрөнгө өмчлөгч</h2> 
                                            <div class="side pull-right">                                                     
                                                <a href="#ownerAddPopup" onclick="addOwnerPopup()" data-toggle=modal class="btn btn-default btn-clean">Нэмэх</a>
                                            </div>
                                        </div> 
                                            <table class="table table-bordered" id="assetOwnerTable"> 
                                                <thead> 
                                                    <tr> 
                                                        <th>#</th>                                                             
                                                        <th>Нэр</th> 
                                                        <th>Регистрийн дугаар</th> 
                                                        <th>Утас</th>                                                             
                                                    </tr> 
                                                </thead> 
                                                <tbody id="assetOwnerTbody"> 

                                                </tbody> 
                                            </table> 
                                            <input type="hidden" id="hiddenAssetOwnerCount" value="0">
                                    </div>
                                </div>                   
                            </div>
                            <div class="tab-pane" id="tab21">                                
                                <div class="col-md-12">
                                    <div class="block"> 
                                        <div class="header"> 
                                            <h2>Хамтран зээлдэгч</h2> 
                                            <div class="side pull-right">                                                     
                                                <a href="#partnerAddPopup" onclick="openPartner()" data-toggle=modal class="btn btn-default btn-clean">Нэмэх</a>
                                            </div>
                                        </div> 
                                        <table class="table table-bordered" id="partnerTable"> 
                                            <thead> 
                                                <tr> 
                                                    <th width="5%">#</th>                                                             
                                                    <th width="60%">Нэр</th> 
                                                    <th width="25%">Регистрийн дугаар</th> 
                                                    <th width="10%">Утас</th>                                                             
                                                </tr> 
                                            </thead> 
                                            <tbody id="partnerTableTbody"> 

                                            </tbody>
                                        </table> 
                                        <input type="hidden" id="hiddenPartnerCount" value="0">
                                    </div>
                                </div>                                
                            </div>
                            
                        </div>
                    </div>
                </div>
            </div>            
        </div>
        <div class="row">
            <div class=footer> 
                <div class="side"> 
                    <div class="btn-group margin-left-10"> 
                        <button class="btn btn-success" name="save" value="1" type=submit>Хадгалах</button> 
                    </div> 
                </div> 
            </div> 
        </div>
        <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}"/>
    </form> 
    
    <div class="modal" id="ownerAddPopup" role="dialog" aria-labelledby="ownerAddPopup" aria-hidden="true">
        <div class=modal-dialog>
            <div class=modal-content>
                <div class=modal-header>
                    <button type=button class=close data-dismiss=modal aria-hidden=true>&times;</button>
                    <h4 class=modal-title>Барьцаа хөрөнгө өмчлөгч</h4>
                </div>
                <div class="modal-body clearfix">
                    
                    <div class="form-row"> 
                        <div class="col-md-3">Эзэмшигч нь : </div> 
                        <div class="col-md-9"> 
                            <div class=checkbox-inline> 
                                <label> <input type="radio" class="" value="1" name="owner_popup_choose" id="owner_popup_citizen" onclick="ownerChoose(1)"/> Иргэн </label>
                            </div> 
                            <div class=checkbox-inline> 
                                <label> <input type="radio" class="" value="2" name="owner_popup_choose" id="owner_popup_legal_entity" onclick="ownerChoose(2)"/> Хуулийн этгээд </label>
                            </div> 
                        </div>
                    </div>
                    
                    <div class="controls hide" id="owner_citizen_wrapper">
                        <div class="form-row">
                            <div class="col-md-12">
                                <label>Ургын овог</label>
                                <input type="text" class="form-control" value="" name="owner_popup_family_name" id="owner_popup_family_name"/>
                            </div>
                        </div>                        
                        <div class="form-row">
                            <div class="col-md-12">
                                <label>Эцэг/Эхийн нэр</label>
                                <input type="text" class="form-control" value="" name="owner_popup_last_name" id="owner_popup_last_name"/>
                            </div>
                        </div>                        
                        <div class="form-row">
                            <div class="col-md-12">
                                <label>Өөрийн нэр</label>
                                <input type="text" class="form-control" value="" name="owner_popup_first_name" id="owner_popup_first_name"/>
                            </div>
                        </div>                        
                        <div class="form-row">
                            <div class="col-md-12">
                                <label>Регистрийн дугаар</label>
                                <input type="text" class="form-control" value="" name="owner_popup_register_number" id="owner_popup_register_number"/>
                            </div>
                        </div>                        
                        <div class="content controls">
                            <div class="form-row"> 
                                <div class="col-md-3">Аймаг / Нийслэл : </div> 
                                <div class="col-md-9"> 
                                    <select class="select2" style="width:100%" tabindex="10" name="owner_popup_address_1" id="owner_popup_address_1"> 
                                        <option value="">Сонгох</option>
                                    </select>
                                </div> 
                            </div>
                            <div class="form-row"> 
                                <div class="col-md-3">Сум/Дүүрэг : </div> 
                                <div class="col-md-9"> 
                                    <select class="select2" style="width:100%" tabindex="11" name="owner_popup_address_2" id="owner_popup_address_2"> 
                                        <option value="">Сонгох</option>
                                    </select>
                                </div> 
                            </div>
                            <div class="form-row"> 
                                  <div class="col-md-3">Хаяг:</div> 
                                  <div class="col-md-9"><textarea class="form-control" tabindex="12" name="owner_popup_address_full" id="owner_popup_address_full"></textarea>
                                  </div> 
                            </div>                            
                            <div class="form-row">
                                <div class="col-md-12">
                                    <label>Утасны дугаар</label>
                                    <input type="text" class="form-control" value="" name="owner_popup_first_name" id="owner_popup_phone"/>
                                </div>
                            </div>                        
                            <div class="form-row">
                                <div class="col-md-12">
                                    <label>И-мэйл</label>
                                    <input type="email" class="form-control" value="" name="owner_popup_register_number" id="owner_popup_email"/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="controls hide" id="owner_legal_entity_wrapper">                                  
                        <div class="form-row">
                            <div class="col-md-12">
                                <label>Нэр</label>
                                <input type="text" class="form-control" value="" name="owner_popup_lentity_name" id="owner_popup_lentity_name"/>
                            </div>
                        </div>                        
                        <div class="form-row">
                            <div class="col-md-12">
                                <label>Регистрийн дугаар</label>
                                <input type="text" class="form-control" value="" name="owner_popup_lentity_register_number" id="owner_popup_lentity_register_number"/>
                            </div>
                        </div>                        
                        <div class="content controls">
                            <div class="form-row"> 
                                <div class="col-md-3">Аймаг / Нийслэл : </div> 
                                <div class="col-md-9"> 
                                    <select class="select2" style="width:100%" tabindex="10" name="owner_popup_lentity_address_1" id="owner_popup_lentity_address_1"> 
                                        <option value="">Сонгох</option>
                                    </select>
                                </div> 
                            </div>
                            <div class="form-row"> 
                                <div class="col-md-3">Сум/Дүүрэг : </div> 
                                <div class="col-md-9"> 
                                    <select class="select2" style="width:100%" tabindex="11" name="owner_popup_lentity_address_2" id="owner_popup_lentity_address_2"> 
                                        <option value="">Сонгох</option>
                                    </select>
                                </div> 
                            </div>
                            <div class="form-row"> 
                                  <div class="col-md-3">Хаяг:</div> 
                                  <div class="col-md-9"><textarea class="form-control" tabindex="12" name="owner_popup_lentity_address_full" id="owner_popup_lentity_address_full"></textarea>
                                  </div> 
                            </div>                            
                            <div class="form-row">
                                <div class="col-md-12">
                                    <label>Утасны дугаар</label>
                                    <input type="text" class="form-control" value="" name="owner_popup_lentity_phone" id="owner_popup_lentity_phone"/>
                                </div>
                            </div>                        
                            <div class="form-row">
                                <div class="col-md-12">
                                    <label>И-мэйл</label>
                                    <input type="email" class="form-control" value="" name="owner_popup_lentity_email" id="owner_popup_lentity_email"/>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class=modal-footer>
                    <button type=button class="btn btn-default btn-clean" data-dismiss=modal>Хаах</button>
                    <button type=button class="btn btn-success btn-clean" onclick="addOwner()">Нэмэх</button>
                </div>
            </div>
        </div>
    </div>
    
    <div class="modal" id="partnerAddPopup" role="dialog" aria-labelledby="ownerAddPopup" aria-hidden="true">
        <div class=modal-dialog>
            <div class=modal-content>
                <div class=modal-header>
                    <button type=button class=close data-dismiss=modal aria-hidden=true>&times;</button>
                    <h4 class=modal-title>Хамтран зээлдэгч</h4>
                </div>
                <div class="modal-body clearfix">
                    <div class="col-md-12" id="partner_popup_flash"></div>
                    <div class="controls" id="partner_wrapper">
                        <div class="form-row">
                            <div class="col-md-12">
                                <label class="required">*</label> Хамтран зээлдэгчийн төрөл
                                
                                <select class="select2 col-md-12 padding-none" name="partner_popup_type" id="partner_popup_type"> 
                                    <option value="">Сонгох</option>
                                    {% for type in creditType %}
                                        <option value="{{type.id}}">{{type.name}}</option>
                                    {% endfor %}
                                </select>
                            </div>
                        </div>  
                        <div class="form-row">
                            <div class="col-md-12">
                                <label class="required">*</label> Ургын овог
                                <input type="text" class="form-control" value="" name="owner_popup_family_name" id="partner_popup_family_name"/>
                            </div>
                        </div>                        
                        <div class="form-row">
                            <div class="col-md-12">
                                <label class="required">*</label> Эцэг/Эхийн нэр                                
                                <input type="text" class="form-control" value="" name="owner_popup_last_name" id="partner_popup_last_name"/>
                            </div>
                        </div>                        
                        <div class="form-row">
                            <div class="col-md-12">
                                <label class="required">*</label> Өөрийн нэр
                                <input type="text" class="form-control" value="" name="owner_popup_first_name" id="partner_popup_first_name"/>
                            </div>
                        </div>                        
                        <div class="form-row">
                            <div class="col-md-12">
                                <label class="required">*</label> Регистрийн дугаар
                                <input type="text" class="form-control" value="" name="owner_popup_register_number" id="partner_popup_register_number"/>
                            </div>
                        </div>                        
                        <div class="content controls">
                            <div class="form-row"> 
                                <div class="col-md-3">Аймаг / Нийслэл : </div> 
                                <div class="col-md-9"> 
                                    <select class="select2" style="width:100%" tabindex="10" name="partner_popup_address_1" id="partner_popup_address_1"> 
                                        <option value="">Сонгох</option>
                                    </select>
                                </div> 
                            </div>
                            <div class="form-row"> 
                                <div class="col-md-3">Сум/Дүүрэг : </div> 
                                <div class="col-md-9"> 
                                    <select class="select2" style="width:100%" tabindex="11" name="partner_popup_address_2" id="partner_popup_address_2"> 
                                        <option value="">Сонгох</option>
                                    </select>
                                </div> 
                            </div>
                            <div class="form-row"> 
                                  <div class="col-md-3">Хаяг:</div> 
                                  <div class="col-md-9"><textarea class="form-control" tabindex="12" name="partner_popup_address_full" id="partner_popup_address_full"></textarea>
                                  </div> 
                            </div>                            
                            <div class="form-row">
                                <div class="col-md-12">
                                    <label class="required">*</label> Утасны дугаар
                                    <input type="text" class="form-control" value="" name="partner_popup_phone" id="partner_popup_phone"/>
                                </div>
                            </div>                        
                            <div class="form-row">
                                <div class="col-md-12">
                                    <label>И-мэйл</label>
                                    <input type="email" class="form-control" value="" name="partner_popup_email" id="partner_popup_email"/>
                                </div>
                            </div>
                        </div>
                    </div>                    
                </div>
                
                <div class=modal-footer>
                    <button type=button class="btn btn-default btn-clean" data-dismiss=modal>Хаах</button>
                    <button type=button class="btn btn-success btn-clean" onclick="addPartner()">Нэмэх</button>
                </div>
            </div>
        </div>
    </div>
                                
    <div class="modal" id="contractPopup" role="dialog" aria-labelledby="contractPopup" aria-hidden="true">
        <div class=modal-dialog>
            <div class=modal-content>
                <div class=modal-header>
                    <button type=button class=close data-dismiss=modal aria-hidden=true>&times;</button>
                    <h4 class=modal-title>Зээлийн гэрээ бүртгэх</h4>
                </div>
                <div class="modal-body clearfix">
                    <div class="col-md-12" id="partner_popup_flash"></div>
                    <div class="controls" id="partner_wrapper">
                        <div class="form-row">
                            <div class="col-md-12">
                                <label class="required">*</label> Зээлийн гэрээний төрөл
                                
                                <select class="select2 col-md-12 padding-none" name="contract_popup_type" id="contract_popup_type" required="required"> 
                                    <option value="">Сонгох</option>
                                    {% for type in creditType %}
                                        <option value="{{type.id}}">{{type.name}}</option>
                                    {% endfor %}
                                </select>
                            </div>
                        </div>  
                        <div class="form-row">
                            <div class="col-md-12">
                                <label class="required">*</label> Зээлдэгчийн регистрийн дугаар                           
                                <input type="text" class="form-control" value="" name="contract_target_register" id="contract_target_register" required="required"/>
                            </div>
                        </div>                        
                        <div class="form-row">
                            <div class="col-md-12">
                                Зээлийн гэрээний нэр
                                <input type="text" class="form-control" value="" name="contract_name" id="contract_name"/>
                            </div>
                        </div>                        
                        <div class="form-row">
                            <div class="col-md-12">
                                <label class="required">*</label> Гэрээ байгуулсан огноо
                                <input type="text" class="form-control datepicker" value="" name="contract_signed_date" id="contract_signed_date" required="required"/>                                
                            </div>
                        </div>
                        <div class="form-row">
                            <div class="col-md-12">
                                <label class="required">*</label> Гэрээ мөрдөж эхлэх огноо
                                <input type="text" class="form-control datepicker" value="" name="contract_begin_date" id="contract_begin_date" required="required"/>
                            </div>
                        </div>
                                
                        <div class="form-row">
                            <div class="col-md-12">
                                Гэрээ дуусах огноо
                                <input type="text" class="form-control datepicker" value="" name="contract_end_date" id="contract_end_date"/>
                            </div>
                        </div>
                                
                        <div class="form-row"> 
                            <div class="col-md-3">Тайлбар:</div> 
                                <div class="col-md-9">
                                    <textarea class="form-control" tabindex="12" name="contract_description" id="contract_description"></textarea>
                                </div> 
                        </div> 
                        
                    </div>                    
                </div>
                
                <div class=modal-footer>
                    <button type=button class="btn btn-default btn-clean" data-dismiss=modal>Хаах</button>
                    <button type=button class="btn btn-success btn-clean" onclick="addContract()">Нэмэх</button>
                </div>
            </div>
        </div>
    </div>

{% endblock %}